import axios from 'axios';
import {GET_DATA} from './actionTypes';

const setDataAction=(data)=>{
    return {
        type:GET_DATA,
        data
    }
}

export const getDataAction=(id)=>{
    return (dispatch)=>{
        axios.get(`https://www.fastmock.site/mock/eaa7a18e424aefd6b9ee29850969298e/api/detail?id=${id}`).then(res=>{
            const data=res.data.data;
            const action=setDataAction(data);
            dispatch(action);
        }).catch(()=>{
            console.log('error')
        })
    }
}